home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / language / dino / dino_bot.1 / source / shell / line.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-03-10  |  1.1 KB  |  54 lines

  1. /* Copyright, 1990, Regents of the University of Colorado */
  2. #include <stdio.h>
  3. #include <string.h>
  4. #include <strings.h>
  5. #include <fcntl.h>
  6. #include "shell.h"
  7.  
  8. FILE *outfile;
  9.  
  10. void entry(phys, entries)
  11.     int phys; /*physical line number in file of last entry*/
  12.     int entries; /*number of entries so far*/
  13.     {
  14.     int count = phys; /*line number of lines looked at*/
  15.     int logical; /*start of segment*/
  16.     char file[FILENAME]; 
  17.     static char *line;
  18.     do{
  19.         char *name, *q1,*q2;
  20.         line = get_line(0);
  21.         if (*line == '#') {
  22.             logical = strtol(&line[1], &name, 10);
  23.             q1 = strchr(line,'"');
  24.             q2 = strchr(q1+1,'"');
  25.             strncpy(file,q1,(q2-q1)+1);
  26.             file[(q2-q1)+2] = '\0';
  27.             }
  28.         else if(*line != '\0'){
  29.             count++;
  30.             printf("%s",line);
  31.             }
  32.         else eof = TRUE;
  33.     } while (!eof && (*line != '#'));
  34.     if (!eof){
  35.         entry(count, entries+1);
  36.         fprintf(outfile,"%d %d %s\n",count,logical,file);
  37.         }
  38.     else
  39.         fprintf(outfile,"%d\n",entries);
  40.     }
  41.  
  42.  
  43. int main(argc, argv)
  44.     int argc;
  45.     char *argv[];
  46.     {
  47.     char sourcename[FILENAME];
  48.  
  49.     strcpy(sourcename, argv[1]);
  50.     outfile = fopen(sourcename,"w");
  51.     entry(1,0);
  52.     return(0);
  53.     }
  54.